package com.zhengjiang.newdate;

import java.util.Calendar;
import java.util.Date;

/**
 * @author zhengjiang
 * @version 1.0.0
 * @description
 * @date 2021/6/3
 **/
public class CalendarTest {
    public static void main(String[] args) throws InterruptedException {
        Calendar c1 = Calendar.getInstance();
        Date date = c1.getTime();
        System.out.println(date);
        System.out.println(c1.get(Calendar.YEAR));
        System.out.println(c1.get(Calendar.MONTH) + 1);
        System.out.println(c1.get(Calendar.DATE));

        c1.add(Calendar.YEAR,-1);
        System.out.println(c1.getTime());

        Thread.sleep(3000);
        Calendar c2 = Calendar.getInstance();
        c2.setTime(date);
        System.out.println(c2.getTime());
    }
}
